//
//  UIScrollView+YSExtension.m
//  YSWeChat
//
//  Created by MOLBASE on 2018/4/15.
//  Copyright © 2018年 YangShen. All rights reserved.
//

#import "UIScrollView+YSExtension.h"

@implementation UIScrollView (YSExtension)

/// 添加下拉刷新控件
- (MJRefreshNormalHeader *)ys_addHeaderRefresh:(void(^)(MJRefreshNormalHeader *header))refreshingBlock {
    @weakify(self);
    MJRefreshNormalHeader *mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        @strongify(self);
        !refreshingBlock?:refreshingBlock((MJRefreshNormalHeader *)self.mj_header);
    }];
    mj_header.lastUpdatedTimeLabel.hidden = YES;
    // Configure normal mj_header
    self.mj_header = mj_header;
    return mj_header;
}

/// 添加上拉加载控件
- (MJRefreshAutoNormalFooter *)ys_addFooterRefresh:(void(^)(MJRefreshAutoNormalFooter *footer))refreshingBlock {
    @weakify(self);
    MJRefreshAutoNormalFooter *mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        @strongify(self);
        !refreshingBlock?:refreshingBlock((MJRefreshAutoNormalFooter *)self.mj_footer);
    }];
    // Configure normal mj_footer
    [mj_footer setTitle:@"别拉了，已经到底了..." forState:MJRefreshStateNoMoreData];
    self.mj_footer = mj_footer;
    return mj_footer;
}

@end
